package com.example.bitmapandcachedemo.imageloader;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.AbsListView;
import android.widget.GridView;

import com.example.bitmapandcachedemo.R;

import java.util.Arrays;

/**
 * Created by tangjiangxu on 11/8/17.
 */

public class PhotoWallActivity extends Activity {
    private GridView mGridView;
    private ImageAdapter mImageAdapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_photowall);

        mGridView = findViewById(R.id.gridview);
        mGridView.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {
                if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
                    ImageAdapter.mIsGridViewIdle = true;
                    mImageAdapter.notifyDataSetChanged();
                } else {
                    ImageAdapter.mIsGridViewIdle = false;
                }
            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

            }
        });
        mImageAdapter = new ImageAdapter(this, Arrays.asList(ImageInfo.IMAGE_URL_LIST));
        mGridView.setAdapter(mImageAdapter);

    }
}
